#include <iostream>
using namespace std;

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>

int main()
{   
    const char * filename = "test.txt";

    //打开文件
    int fd1 = open(filename,O_RDWR | O_CREAT,0644);
    cout<<"fd1:"<<fd1<<endl;

    //打开文件
    int fd2 = open(filename,O_RDWR );
    cout<<"fd2:"<<fd2<<endl;

    //打开文件
    int fd3 = open(filename,O_RDWR );
    cout<<"fd3:"<<fd3<<endl;

    close(fd1);
    //打开文件
    int fd4 = open(filename,O_RDWR );
    cout<<"fd4:"<<fd4<<endl;
    //关闭文件
    close(fd2);
    close(fd3);
    close(fd4);

    return 0;
}